package com.ocm.tourism.core.domain;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.TableGenerator;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.springframework.beans.factory.annotation.Configurable;

@Configurable
@Entity
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
public class Business {

   @NotNull
   @Size(max = 150)
   private String name;

   @NotNull
   @Size(max = 150)
   private String address;

   @ManyToOne
   private CommonItems countryId;

   @ManyToOne
   private CommonItems cityId;

   @Size(max = 10)
   private String mobilephone;

   @Size(max = 15)
   private String homephone;

   @Size(max = 15)
   private String fax;

   @Size(max = 4000)
   private String description;

   @NotNull
   @Enumerated(EnumType.STRING)
   private BusinessType businessType;

   @OneToOne(cascade=CascadeType.ALL)
   private FileInfo avatar;

   @OneToOne(cascade=CascadeType.ALL)
   private Comment latestComment;

   private Date createdDate;

   @OneToOne(cascade=CascadeType.ALL)
   private Advertisement advertisement;

   @ManyToOne
   private Participant participant;

   public String toString() {
      return ReflectionToStringBuilder.toString(this, ToStringStyle.SHORT_PREFIX_STYLE);
   }

   public String getName() {
      return this.name;
   }

   public void setName(String name) {
      this.name = name;
   }

   public String getAddress() {
      return this.address;
   }

   public void setAddress(String address) {
      this.address = address;
   }

   public CommonItems getCountryId() {
      return this.countryId;
   }

   public void setCountryId(CommonItems countryId) {
      this.countryId = countryId;
   }

   public CommonItems getCityId() {
      return this.cityId;
   }

   public void setCityId(CommonItems cityId) {
      this.cityId = cityId;
   }

   public String getMobilephone() {
      return this.mobilephone;
   }

   public void setMobilephone(String mobilephone) {
      this.mobilephone = mobilephone;
   }

   public String getHomephone() {
      return this.homephone;
   }

   public void setHomephone(String homephone) {
      this.homephone = homephone;
   }

   public String getFax() {
      return this.fax;
   }

   public void setFax(String fax) {
      this.fax = fax;
   }

   public String getDescription() {
      return this.description;
   }

   public void setDescription(String description) {
      this.description = description;
   }

   public BusinessType getBusinessType() {
      return businessType;
   }

   public void setBusinessType(BusinessType businessType) {
      this.businessType = businessType;
   }

   @Id
   @GeneratedValue(strategy=GenerationType.TABLE,generator="GEN_BUS")
   @TableGenerator(name = "GEN_BUS", table = "SEQUENCE_LIST", allocationSize = 1, initialValue = 1, pkColumnName = "NAME", valueColumnName = "NEXT_SEQUENCE", pkColumnValue = "BUSINESS")
   private Long id;

   @Version
   @Column(name = "version")
   private Integer version;

   public Long getId() {
      return this.id;
   }

   public void setId(Long id) {
      this.id = id;
   }

   public Integer getVersion() {
      return this.version;
   }

   public void setVersion(Integer version) {
      this.version = version;
   }

   public FileInfo getAvatar() {
      return avatar;
   }

   public void setAvatar(FileInfo avatar) {
      this.avatar = avatar;
   }

   public Date getCreatedDate() {
      return createdDate;
   }

   public void setCreatedDate(Date createdDate) {
      this.createdDate = createdDate;
   }

   public Comment getLatestComment() {
      return latestComment;
   }

   public void setLatestComment(Comment latestComment) {
      this.latestComment = latestComment;
   }

   public Participant getParticipant() {
      return participant;
   }

   public void setParticipant(Participant participant) {
      this.participant = participant;
   }

   public Advertisement getAdvertisement() {
      return advertisement;
   }

   public void setAdvertisement(Advertisement advertisement) {
      this.advertisement = advertisement;
   }
}
